<template>
  <div class="app-container">
    <el-tabs>
      <!--Element Icon-->
      <el-tab-pane label="ElementIcons">
        <div class="grid">
          <div v-for="item of elementIcons" :key="item" @click="handleClipboard(generateElementIconCode(item), $event)">
            <el-tooltip class="item" placement="top-start">
              <div slot="content">
                {{ generateElementIconCode(item) }}
              </div>
              <div class="icon-item">
                <i :class="'el-icon-' + item" />
                <span>{{ item }}</span>
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
      <!--Svg Icon-->
      <el-tab-pane label="SvgIcons">
        <div class="grid">
          <div v-for="item of svgIcons" :key="item" @click="handleClipboard(generateIconCode(item), $event)">
            <el-tooltip class="item" effect="dark" placement="top-start">
              <div slot="content">
                {{ generateIconCode(item) }}
              </div>
              <div class="icon-item">
                <svg-icon :icon-class="item" class-name="disabled" />
                <span>{{ item }}</span>
              </div>
            </el-tooltip>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import elementIcons from './element-icons'
import svgIcons from './svg-icons'
import clipboard from '@/utils/clipboard'

export default {
  data() {
    return {
      elementIcons,
      svgIcons
    }
  },
  mounted() {
    this.svgList()
  },
  methods: {
    svgList() {
      console.log(this.svgIcons)
    },
    generateElementIconCode(iconName) {
      return `<i class="el-icon-${iconName}" />`
    },
    generateIconCode(iconName) {
      return `<svg-icon icon-class="${iconName}" />`
    },
    handleClipboard(text, event) {
      clipboard(text, event)
    }
  }
}
</script>

<style lang="scss" scoped>
  .grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .icon-item {
    margin: 20px;
    width: 100px;
    height: 85px;
    text-align: center;
    font-size: 30px;
    color: #24292e;
    cursor: pointer;
  }
  span {
    display: block;
    font-size: 16px;
    margin-top: 10px;
  }
  .disabled {
    pointer-events: none;
  }
</style>
